﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data.SqlClient;
using System.Data;

public partial class _Default : System.Web.UI.Page 
{
    /*page defaults*/
    OfficeOnlineUser currentUser;
 
    private void AuthenticateUser()
    {
        try
        {
            currentUser = (OfficeOnlineUser)Session["CurrentUser"];
        }
        catch (Exception ex)
        {
            Response.Redirect("../login.aspx?urlReferrer=" + Request.Url);
        }

        if (currentUser == null)
        {
            Response.Redirect("../login.aspx?urlReferrer=" + Request.Url);
        }
    }
    /*end page defaults*/
    
    protected void Page_Load(object sender, EventArgs e)
    {
        
        AuthenticateUser();     //should be called by all pages;
        //else
        //{
        //     lblUser.Text = currentUser.UserRealName;
        //     DisplayForAdminUser();
        //     DisplayForManagement();
        //}
        lblUser.Text = currentUser.UserRealName;
        txtCurrentUser.Value = currentUser.UserName;
        DisplayForAdminUser();
        DisplayForManagement();
        //BindRemindersTable();
    }

    
    protected void btnLogout_Click(object sender, EventArgs e)
    {
        
    }

    private void DisplayForAdminUser()
    {
        
        if (currentUser.UserType > 1)
        {
            divAdmin.Visible = true;
            divCreateUserScripts.Visible = true;
            divManageUserScripts.Visible = true;
        }
    }

    private void DisplayForManagement()
    {
        if (currentUser.UserType > 1)
        {
            divAdmin.Visible = true;
            divCreateUserScripts.Visible = true;
            divManageUserScripts.Visible = true;
        }
    }
}
